#include "internal.h"

/*
 * If the scheduling parameters of a -deadline task changed,
 * a push or pull operation might be needed.
 */
static void prio_changed_dl(struct rq *rq, struct task_struct *p,
                            int oldprio)
{
    if (!task_on_rq_queued(p))
        return;

    /*
     * This might be too much, but unfortunately
     * we don't have the old deadline value, and
     * we can't argue if the task is increasing
     * or lowering its prio, so...
     */
    if (!rq->dl.overloaded)
        deadline_queue_pull_task(rq);

    if (task_current_donor(rq, p))
    {
        /*
         * If we now have a earlier deadline task than p,
         * then reschedule, provided p is still on this
         * runqueue.
         */
        if (dl_time_before(rq->dl.earliest_dl.curr, p->dl.deadline))
            resched_curr(rq);
    }
    else
    {
        /*
         * Current may not be deadline in case p was throttled but we
         * have just replenished it (e.g. rt_mutex_setprio()).
         *
         * Otherwise, if p was given an earlier deadline, reschedule.
         */
        if (!dl_task(rq->curr) ||
            dl_time_before(p->dl.deadline, rq->curr->dl.deadline))
            resched_curr(rq);
    }
}
